program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  arr = array of integer;

var
  mass: array of arr;
  v, e, i, j, a, b: integer;
begin
  read (v, e);
  setlength (mass, v, v);
  for i := 0 to v-1  do
    for j := 0 to v-1 do
      mass[i, j]:= 0;
  for i := 0 to e - 1 do
  begin
    read (a, b);
    mass[a-1, b-1]:= 1;
  end;
  for i := 0 to v-1 do
  begin
    for j := 0 to v-1 do
      write (mass [i, j], ' ');
    writeln;
  end;
end.
